<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%String path=request.getContextPath();
String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>">
	<title><s:text name="sys.app_title" />
	</title> <%@include file="../include/contentheader.jsp"%>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<link rel="stylesheet" type="text/css" href="css/main.css" />
	<link rel="stylesheet" type="text/css" href="css/dtree.css" />
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="js/jquery.blockUI.js"></script>
	<script type="text/javascript" src="js/dtree.js"></script>
	<script type="text/javascript" src="js/app.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/engine.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/util.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/interface/categoryManager.js"></script>
</head>

<body>
<div class="mainContainer">
	<div class="headerTitle">日常信息管理&nbsp;>>&nbsp;资产内部调动</div>
		<div class="dtreeDiv" id="managerTree">
			<script type="text/javascript">
				var myTree = document.getElementById("managerTree");
				d = new dTree('d');
				var inner;
				buildTree();
				function buildTree(){
					categoryManager.findAllCategory(function(category) {
						d.add(0, -1, '广元电业局',"searchInner.action?FN=<s:property value='FN' />");
						for(var i=0; i<category.length; i++){
							var size = category[i].catid.length;
							var url = "queryAssetInnerMoveInTree.action?FN=<s:property value='FN' />&catid="+category[i].catid;
							if(size == 3){
								d.add(category[i].catid,0,category[i].catname,url);
							}else if(size == 6){
								d.add(category[i].catid,category[i].catid.substr(0,3),category[i].catname,url);
							}else if(size == 10){
								d.add(category[i].catid,category[i].catid.substr(0,6),category[i].catname,url);
							}
						}
						inner = d.toString();
						showBuildTree();
					});
				}
				function showBuildTree() {
					myTree.innerHTML = inner;
				}
			</script>
		</div>
		<div class="dataDivLeftHasTree">
		<table class="gridTable" border="0" cellspacing="0" cellpadding="0">
			<tr class="operatorAction">
				<td>
					<s:if test="accessRight.indexOf('V')!=-1">
						<input type="button" style="margin-left:2px;" value="刷新" onclick="refresh();"/>
					</s:if>
					<s:if test="accessRight.indexOf('P')!=-1">
						<input type="button" style="margin-left:2px;" value="经办申请" onclick="apply();" />
					</s:if>
					<s:if test="accessRight.indexOf('R')!=-1">
						<input type="button" style="margin-left:2px;" value="经办上报" onclick="report();" />
					</s:if>
					<s:if test="accessRight.indexOf('A')!=-1">
						<input type="button" style="margin-left:2px;" value="领导审核" onclick="declaration();" />
					</s:if>
					<s:if test="accessRight.indexOf('B')!=-1">
						<input type="button" style="margin-left:2px;" value="领导退回" onclick="untread();" />
					</s:if>
					<s:if test="accessRight.indexOf('E')!=-1">
						<input type="button" style="margin-left:2px;" value="收货确认" onclick="validate();" />
					</s:if>
					<s:if test="accessRight.indexOf('O')!=-1">
						<input type="button" style="margin-left:2px;" value="导出" onclick="exportTable();" />
					</s:if>
					<s:if test="accessRight.indexOf('V')!=-1">
						查询条件：根据&nbsp;&nbsp;<select style="width: 94px;" id="condition" onblur="acstatusValueBeChosen()">
	  						<option value="acname" selected="selected">资产名称</option>
							<option value="acstatus">资产状态</option>
							<option value="acuser">资产当前使用人</option>
	  					</select>
						
						<input type="text" class="qryTxt" id="conditionValue" />
						
						<select style="display: none;width: 150px" class="qryTxt" id="acstatusValue">
	  						<option value="400" selected="selected">在用</option>
							<option value="501">内调-部门经办已申请</option>
							<option value="502">内调-部门经办已上报</option>
							<option value="503">内调-部门经办已审核</option>
	  					</select>
						
						<input type="button" style="margin-left:1px;" value="查询" onclick="selectAssetCart()"/>
					</s:if>
				</td>
			</tr>
			<tr>
				<td class="gridData">
				
					<table class="dataTable" border="0" cellpadding="0" cellspacing="1">
					  	<tr class="dataHeader">
						  	<td width="2%"><input id="checkAll" type="checkbox" /></td>
						  	<td width="5%">资产卡片编号</td>
							<td width="5%">名称</td>
							<td width="3%">所在部门</td>
							<td width="3%">是否公用</td>
							<td width="5%">状态</td>
							<!-- <td width="5%">使用人</td> -->
							
							<td width="5%">操作人</td>
							<td width="5%">操作角色</td>
							<td width="6%">状态</td>
							<td width="5%">处理结果</td>
							<td width="7%">处理意见</td>
							<td width="5%">处理时间</td>
							<td width="5%">原使用人</td>
							<td width="5%">现使用人</td>
							
							<td width="3%">类别</td>
							<td width="5%">生产日期</td>
							<td width="5%">使用期限</td>
							<td width="5%">预计停用日期</td>
							<td width="5%">采购价格</td>
							<td width="3%">计量单位</td>
							<td width="3%">规格</td>
							<td width="5%">生产厂家</td>
						</tr>
						
						<s:iterator var="ac" value="pagination.dataList" status="sta"> 
						<tr class="dataRow" id="<s:property value='#ac.acid'/>">
							<td><input name="checkbox" type="checkbox" value="<s:property value='#ac.acid' />" /></td>

							<td><s:property value="#ac.acid" /></td>
							<td><s:property value="#ac.acname" /></td>
							<td><s:property value="#ac.depname" /></td>
							<td><s:property value="#ac.ispublic" /></td>
							<td><s:property value="#ac.acstatus" /></td>
							<!-- <td><s:property value="#ac.acuser" /></td> -->
							
							
							<td colspan="8" style="background-color: #ccc;">
								<s:iterator var="bo" value="#ac.book" status="ats">
								
								</s:iterator>
							</td>
							
							
							<!-- <td><s:property value="#ac." /></td>
							<td><s:property value="#ac." /></td>
							<td><s:property value="#ac." /></td>
							<td><s:property value="#ac." /></td>
							<td><s:property value="#ac." /></td>
							<td><s:property value="#ac." /></td>
							<td><s:property value="#ac." /></td>
							<td><s:property value="#ac." /></td> -->
							
							<td><s:property value="#ac.category.catname" /></td>
							<td><s:property value="#ac.producedate" /></td>
							<td><s:property value="#ac.lifetime" /></td>
							<td><s:property value="#ac.planstopdate" /></td>
							<td><s:property value="#ac.orderprice" /></td>
							<td><s:property value="#ac.category.catunit" /></td>
							<td><s:property value="#ac.category.catnorms" /></td>
							<td><s:property value="#ac.producer" /></td>
						</tr>
						</s:iterator>
					</table>
				</td>
			</tr>
			<tr class="dataPager">
				<td>
					<s:property value="pageLink" escapeHtml="false" />
				</td>
			</tr>
		</table>
	</div>
</div>

<script type="text/javascript">
	//刷新
	function refresh(){
		location.href="searchInner.action?FN=<s:property value='FN' />";
	}
	//经办申请
	function apply(){
		var allWhAssetCard = $("input:checked");
		var str="";
		if(allWhAssetCard.length == 0){
			alert("请选择");
		}else{
			for(var i=0;i<allWhAssetCard.length;i++){
				str=str+allWhAssetCard[i].value+",";
			}
			location.href = "updateAssetCardInnerMoveApply.action?FN=<s:property value='FN' />&acidAll="+str;
		}		
	}
	//经办上报
	function report(){
		var allWhAssetCard = $("input:checked");
		var str="";
		if(allWhAssetCard.length == 0){
			alert("请选择");
		}else{
			for(var i=0;i<allWhAssetCard.length;i++){
				str=str+allWhAssetCard[i].value+",";
			}
			location.href = "updateAssetCardInnerMoveReport.action?FN=<s:property value='FN' />&acidAll="+str;
		}	
	}
	//领导审核
	function declaration(){
		//需要弹出对话框要求输入审核通过的原因
		var allWhAssetCard = $("input:checked");
	    if(allWhAssetCard.length == 0){
    		alert("请选择");
	    }else if(allWhAssetCard.length == 1){
	    	var vRValue=showdepartment();
	    	if(vRValue == undefined){
				ideaValue="操作人按了取消键";
			}else if(vRValue==''){
				ideaValue="操作人没有输入审批意见";
				location.href = "updateAssetCardInnerMoveDeclaration.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue=同意";
			}else{
				location.href = "updateAssetCardInnerMoveDeclaration.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue="+vRValue;
			}
	    }else{
	    	alert("每次只能审核操作一个资产");
		}
	}
	//领导退回
	function untread(){
		//需要弹出对话框要求输入退回的原因
		var allWhAssetCard = $("input:checked");
	    if(allWhAssetCard.length == 0){
    		alert("请选择");
	    }else if(allWhAssetCard.length == 1){
	    	var vRValue=showdepartment();
	    	if(vRValue == undefined){
				ideaValue="操作人按了取消键";
			}else if(vRValue==''){
				ideaValue="操作人没有输入审批意见";
				location.href = "updateAssetCardInnerMoveUntread.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue=同意";
			}else{
				location.href = "updateAssetCardInnerMoveUntread.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue="+vRValue;
			}
	    }else{
	    	alert("每次只能退回操作一个资产");
		}	
	}
	//收货人确认
	function validate(){
		var allWhAssetCard = $("input:checked");
		var str="";
		if(allWhAssetCard.length == 0){
			alert("请选择");
		}else{
			for(var i=0;i<allWhAssetCard.length;i++){
				str=str+allWhAssetCard[i].value+",";
			}
			location.href = "updateAssetCardInnerMoveValidate.action?FN=<s:property value='FN' />&acidAll="+str;
		}		
	}
	//导出
	function exportTable(){
		if(confirm("确定要导出所有记录吗?")){
			location.href="excelToolAssetCardInnerMove.action?FN=<s:property value='FN' />";
		} 	
	}
	//条件查询
	function selectAssetCart(){
		var property=document.getElementById("condition");
		var propertyValue=property.options[property.selectedIndex].value;
		if(propertyValue=="acstatus"){
			var propertyBeChoose=document.getElementById("acstatusValue");
			var propertyValueBeChoose=propertyBeChoose.options[propertyBeChoose.selectedIndex].value;
			location.href = "getInnerMoveAssetCardByPageNumberAndValue.action?FN=<s:property value='FN' />&propertyValue="+propertyValue+"&propertyValueBeChoose="+propertyValueBeChoose;
		}else{
			var inputValue=document.getElementById("conditionValue").value;
			location.href = "getInnerMoveAssetCardByPageNumberAndValue.action?FN=<s:property value='FN' />&propertyValue="+propertyValue+"&inputValue="+inputValue;
		}
	}
	//显示意见输入页面
	function showdepartment(){
		var vRValue = window.showModalDialog("page/daily/idea.jsp",null,"dialogWidth=320px;dialogHeight=450px;status=0;scroll=0");
		return vRValue;
	}
	//条件选择
	function acstatusValueBeChosen(){
		var property=document.getElementById("condition");
		var conditionValue=document.getElementById("conditionValue");
		var acstatusValue=document.getElementById("acstatusValue");
		if(property.options[property.selectedIndex].value=="acstatus"){
			conditionValue.style.display="none";	
			acstatusValue.style.display="inline";
		}else{
			conditionValue.style.display="inline";	
			acstatusValue.style.display="none";
		}
	}
	
</script>
</body>
</html>
